package com.junyi;

/**
 * 策略模式
 * @time: 2022/1/20 11:48
 * @version: 1.0
 * @author: junyi Xu
 */
public class BookService2 {


    public void getByType() {
        Integer type = 1;

        switch (type) {
            case 1:
                // 直减金额优惠券
                new MoneyDiscount();
                break;
            case 2:
                // 会员减免
                new VipDiscount();
                break;
            case 3:
                //  满减优惠
                new MoneyDiscountCondition();
                break;
        }
    }



    public class VipDiscount implements Discount {
        @Override
        public void discount() {
            System.out.println("VipDiscount");
        }
    }
    public class MoneyDiscountCondition implements Discount {
        @Override
        public void discount() {
            System.out.println("MoneyDiscountCondition");
        }
    }
    public class MoneyDiscount implements Discount {
        @Override
        public void discount() {
            System.out.println("MoneyDiscount");
        }
    }


    public interface Discount {
        void discount();
    }
}
